package com.qianwei.footpath.manage;

import com.common.baselib.utils.SharedPreferencesUtils;
import com.qianwei.footpath.bean.LocalConfigBean;

public class LocalCacheDataManage {
    private static LocalCacheDataManage instance;
    private static final String SP_BASE = "qianwei_tzc";

    private static LocalConfigBean localConfigBean;

    private LocalCacheDataManage() {
    }

    public static synchronized LocalCacheDataManage getInstance() {
        if (instance == null) {
            instance = new LocalCacheDataManage();
        }
        return instance;
    }

    public static void setLocalConfigData(LocalConfigBean data) {
        localConfigBean = data;
        SharedPreferencesUtils.getInstance().setObject(SP_BASE + "local_config_data", data);
    }

    public static LocalConfigBean getLocalConfigData() {
        LocalConfigBean data = SharedPreferencesUtils.getInstance().getObject(SP_BASE + "local_config_data");
        if (data == null) {
            data = new LocalConfigBean();
        }
        return data;
    }

    public static String getSeverUrl() {
        if (localConfigBean == null) {
            localConfigBean = getLocalConfigData();
        }
        return localConfigBean.getServerUrl();
    }

}
